home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 283_01 / wink.c < prev    next >
C/C++ Source or Header  |  1988-12-08  |  2KB  |  60 lines

  1. /* wink.c -- 9/5/88, d.c.oshel
  2.    */
  3.  
  4. #include "vidinit.h"
  5. extern void setmchnloc( void );
  6.  
  7. void wink( char c )  /* window character out, obeys backspace and newline */
  8. {
  9.  
  10.     if (!Initialized) vid_init(0);
  11.  
  12.     /* newline? */
  13.     if (c == '\n' || c == '\r') col = 80;  /* set range err to force CR */
  14.  
  15.     /* backspace? nondestructive = 8, destructive = 127 */
  16.     else if ( c == '\b' || c == 127)  /* NOTICE:  THIS PATH RETURNS */
  17.     {
  18.         col--;               /* decrement the column */
  19.         if (col < lm)        /* beyond left margin? */
  20.         {
  21.              row--;          /* yes, decrement the line */
  22.              if (row < tm)   /* above top margin? */
  23.              {
  24.                 row = tm;    /* yes, stick at 0,0 -- does not scroll down! */
  25.                 col = lm;
  26.              }
  27.              else col = rm;  /* no, jump to rightmost column */ 
  28.         }
  29.         if (c == 127)   /* destroy existing char on screen */
  30.         {
  31.             rptchar( SPC, 1 );
  32.         }
  33.         goto synch;
  34.     } 
  35.  
  36.     else 
  37.     {
  38.         rptchar( c, 1 );
  39.     }
  40.  
  41.     /* bump x cursor position, do newline or scroll window up if necessary */
  42.  
  43.     if ( col >= rm )      /* need to newline? */
  44.     {
  45.         col = lm;
  46.         if ( row >= bm )  /* need to scroll? */
  47.         {
  48.             row = bm;
  49.             scrollup();
  50.         }
  51.         else row++;
  52.     }
  53.     else col++;
  54.  
  55.     synch:
  56.     if (synchronized) /* update machine cursor */
  57.         setmchnloc();
  58.  
  59. } /* wink */
  60.